package com.kexio.file.storage;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 存储结果
 * 
 * 封装文件存储操作的结果信息
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
public class StorageResult {
    
    /**
     * 是否成功
     */
    private boolean success;
    
    /**
     * 错误信息
     */
    private String errorMessage;
    
    /**
     * 存储桶名称
     */
    private String bucketName;
    
    /**
     * 对象键/路径
     */
    private String objectKey;
    
    /**
     * 存储URL
     */
    private String storageUrl;
    
    /**
     * 文件大小
     */
    private Long fileSize;
    
    /**
     * 内容类型
     */
    private String contentType;
    
    /**
     * 文件哈希值
     */
    private String fileHash;
    
    /**
     * ETag（如果支持）
     */
    private String etag;
    
    /**
     * 存储时间
     */
    private LocalDateTime storageTime;
    
    /**
     * 元数据
     */
    private Map<String, String> metadata;
    
    // ==================== 构造方法 ====================
    
    public StorageResult() {
        this.storageTime = LocalDateTime.now();
    }
    
    public static StorageResult success(String bucketName, String objectKey) {
        StorageResult result = new StorageResult();
        result.setSuccess(true);
        result.setBucketName(bucketName);
        result.setObjectKey(objectKey);
        return result;
    }
    
    public static StorageResult failure(String errorMessage) {
        StorageResult result = new StorageResult();
        result.setSuccess(false);
        result.setErrorMessage(errorMessage);
        return result;
    }
    
    // ==================== Getter/Setter ====================
    
    public boolean isSuccess() {
        return success;
    }
    
    public void setSuccess(boolean success) {
        this.success = success;
    }
    
    public String getErrorMessage() {
        return errorMessage;
    }
    
    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
    
    public String getBucketName() {
        return bucketName;
    }
    
    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }
    
    public String getObjectKey() {
        return objectKey;
    }
    
    public void setObjectKey(String objectKey) {
        this.objectKey = objectKey;
    }
    
    public String getStorageUrl() {
        return storageUrl;
    }
    
    public void setStorageUrl(String storageUrl) {
        this.storageUrl = storageUrl;
    }
    
    public Long getFileSize() {
        return fileSize;
    }
    
    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }
    
    public String getContentType() {
        return contentType;
    }
    
    public void setContentType(String contentType) {
        this.contentType = contentType;
    }
    
    public String getFileHash() {
        return fileHash;
    }
    
    public void setFileHash(String fileHash) {
        this.fileHash = fileHash;
    }
    
    public String getEtag() {
        return etag;
    }
    
    public void setEtag(String etag) {
        this.etag = etag;
    }
    
    public LocalDateTime getStorageTime() {
        return storageTime;
    }
    
    public void setStorageTime(LocalDateTime storageTime) {
        this.storageTime = storageTime;
    }
    
    public Map<String, String> getMetadata() {
        return metadata;
    }
    
    public void setMetadata(Map<String, String> metadata) {
        this.metadata = metadata;
    }
    
    @Override
    public String toString() {
        return "StorageResult{" +
                "success=" + success +
                ", errorMessage='" + errorMessage + '\'' +
                ", bucketName='" + bucketName + '\'' +
                ", objectKey='" + objectKey + '\'' +
                ", storageUrl='" + storageUrl + '\'' +
                ", fileSize=" + fileSize +
                ", contentType='" + contentType + '\'' +
                ", fileHash='" + fileHash + '\'' +
                ", etag='" + etag + '\'' +
                ", storageTime=" + storageTime +
                '}';
    }
}
